﻿using log4net;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;

namespace ServiceGetPersonTrainLenrnInfo
{
    public partial class GetPersonTrainLenrnInfo : ServiceBase
    {


        log4net.ILog Log = log4net.LogManager.GetLogger("MyLog");


        public GetPersonTrainLenrnInfo()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 服务开始
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            Log.Info("服务开始！");
            Result result = new Result();
            try
            {
                //http://10.99.101.28:90/SysBaseInfo.asmx/GetRolesInfo
                string resString = WebApiUtil.HttpPost("http://10.99.101.28:90/SysBaseInfo.asmx/GetRolesInfo", "wyappuser", "1qaz2wsx");

                result = JsonConvert.DeserializeObject<Result>(resString);
                Log.Info(resString);
            }
            catch (Exception ex)
            {
                Log.Info("服务调用时出现异常！" + ex.Message.ToString());
                result.Data = null;
                result.IsSuccess = false;
                result.Message = ex.Message.ToString();
                throw;
            }

        }

        /// <summary>
        /// 服务停止
        /// </summary>
        protected override void OnStop()
        {
            Log.Info("服务停止！");
        }

        /// <summary>
        /// 服务暂停
        /// </summary>
        protected override void OnPause()
        {
            Log.Info("服务暂停！");
        }

        /// <summary>
        /// 暂停->启动
        /// </summary>
        protected override void OnContinue()
        {
            Log.Info("服务器暂停->启动！");
        }

        /// <summary>
        /// 系统关闭时
        /// </summary>
        protected override void OnShutdown()
        {
            Log.Info("服务器关闭！");
        }


    }
}
